export default {
  draw(cfg, group) {
    let classNames = [
      'h-flow-user-task-node',
      'h-flow-node',
    ];
    if (cfg.history) {
      if (cfg.active) {
        classNames.push('h-flow-node-current-active')
      } else if (cfg.passed) {
        classNames.push('h-flow-node-history-passed')
      } else {
        classNames.push('h-flow-node-not-history-passed')
      }
    }
    classNames.push(cfg.isNodeStop ? 'h-flow-node-stop' : '')
    let shape = group.addShape('dom', {
      attrs: {
        width: 70,
        height: 90,
        html: `<div style="padding-top: 20px">
                  <div data-role="userTask" data-id="${cfg.id}" title="${cfg.taskName}" class="${classNames.join(" ")}">
                    ${this.addSvg(cfg)}
                </div>
                <div class="h-flow-node-title" title="${cfg.taskName}">${cfg.taskName}</div>
                ${this.getSubTitleLabel(cfg)}
              </div>`,
        name: 'UserTask',
      },
    });
    return shape;
  },
  getSubTitleLabel(cfg) {
    if(cfg.notify) {
      return `<div title="知会" class="h-flow-user-task-notify-label">[知会]</div>`
    }
    if(cfg.addCountSign) {
      return `<div title="加签" class="h-flow-user-task-notify-label">[加签]</div>`
    }
    return '';
  },
  addSvg(cfg) {
    if (cfg.isNodeStop){
      return `<svg t="1711276872831" class="icon" viewBox="0 0 1027 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12292" width="200" height="200"><path d="M512 7.929204c-279.221239 0-505.20354 226.548673-505.20354 505.769911s226.548673 505.20354 505.20354 505.20354 505.20354-225.982301 505.20354-505.20354c0.566372-279.221239-225.982301-505.769912-505.20354-505.769911z m0 941.309734c-240.707965 0-435.539823-194.831858-435.539823-435.539823 0-240.707965 194.831858-435.539823 435.539823-435.539823s435.539823 194.831858 435.539823 435.539823c0 240.141593-194.831858 435.539823-435.539823 435.539823z" p-id="12293" fill="#ffffff"></path><path d="M471.221239 625.840708c2.265487 2.265487 3.39823 40.778761 40.778761 40.778761 37.380531 0 40.778761-39.079646 40.778761-40.778761l27.185841-368.141593c0-37.380531-30.584071-67.964602-67.964602-67.964602s-67.964602 30.584071-67.964602 67.964602l27.185841 368.141593z m-13.59292 156.884956c0 30.017699 24.353982 54.371681 54.371681 54.371681s54.371681-24.353982 54.371681-54.371681-24.353982-54.371681-54.371681-54.371682-54.371681 24.353982-54.371681 54.371682z" p-id="12294" fill="#ffffff"></path></svg>`
    }else if (cfg.passed) {
      return `<svg t="1711084467257" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="46901" width="50" height="50"><path d="M860.048 375.018 522.717 712.35l-63.366 63.365c-8.387 8.387-20.035 13.045-31.684 13.045-11.647 0-23.296-4.658-31.683-13.045l-63.366-63.365L163.953 543.684c-8.387-8.387-13.047-20.035-13.047-31.683s4.66-23.296 13.047-31.683l63.365-63.366c8.387-8.387 20.035-13.046 31.684-13.046s23.296 4.659 31.683 13.046l136.982 137.447 305.648-306.113c8.387-8.387 20.035-13.046 31.683-13.046 11.648 0 23.297 4.659 31.684 13.046l63.366 63.366c8.387 8.387 13.046 20.035 13.046 31.683C873.094 354.983 868.435 366.631 860.048 375.018z" p-id="46902" fill="#ffffff"></path></svg>`
    } else if (cfg.active) {
      return `<svg t="1711084538944" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="49699" width="200" height="200"><path d="M423.68896 518.4A216.32 216.32 0 0 0 640.00896 304a218.88 218.88 0 0 0-437.12 0A216.96 216.96 0 0 0 423.68896 518.4z m192 211.84a256 256 0 0 1 48-149.12A423.04 423.04 0 0 0 512.00896 516.48L423.68896 584.32 335.36896 516.48A426.24 426.24 0 0 0 0.00896 935.68h716.16a259.84 259.84 0 0 1-103.68-205.44z" p-id="49700" fill="#ffffff"></path><path d="M848.00896 541.44A176 176 0 1 0 1024.00896 717.44a176 176 0 0 0-176-176z m80 192l-87.04-12.16a12.16 12.16 0 0 1-10.24-13.44l11.52-75.52a12.16 12.16 0 0 1 13.44-8.32c6.4 0 11.52 6.4 10.88 11.52l-10.24 64 75.52 10.88a11.52 11.52 0 0 1 9.6 13.44 12.16 12.16 0 0 1-13.44 11.52z" p-id="49701" fill="#ffffff"></path></svg>`
    } else {
      return `<svg t="1711277270181" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="26109" width="200" height="200"><path d="M515.3894161 257.14149733m-240.57315625 0a240.57315623 240.57315623 0 1 0 481.14631395 0 240.57315623 240.57315623 0 1 0-481.14631395 0Z" p-id="26110" fill="#ffffff"></path><path d="M515.3894161 545.82928539c-72.07375341 0-137.86314777-26.51214381-188.53080037-70.30627713C209.61602423 574.50167844 130.47236583 762.83609159 130.47236583 978.86096749h384.91705027l-48.11463037-72.27014062L515.3894161 545.82928539zM703.92021645 475.52300826c-50.66765259 43.79413334-116.45704697 70.30627715-188.53080035 70.30627713l48.11463183 360.95792872L515.3894161 978.86096749h384.91705173c0-216.02487591-79.1436584-404.35928906-196.38625138-503.33795923z" p-id="26111" fill="#ffffff"></path></svg>`
    }
  },
  getAnchorPoints() {
    return [
      [0, 0.5],
      [1, 0.5]
    ];
  },
};
